<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class thoigianhoc_db 
	{
		public function Them($MaThoiGianHoc, $MaTrangThai, $ChuThich, $SoTietMoiBuoiHoc)
		{
			$sql = "INSERT INTO `tbl_thoigianhoc`(`MaThoiGianHoc`, `MaTrangThai`, `ChuThich`, `SoTietMoiBuoiHoc`)
					VALUES ('$MaThoiGianHoc', '$MaTrangThai', '$ChuThich', '$SoTietMoiBuoiHoc')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaThoiGianHoc)
		{
			$sql = "DELETE FROM `tbl_thoigianhoc` WHERE `MaThoiGianHoc` = '$MaThoiGianHoc'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaThoiGianHoc, $MaTrangThai, $ChuThich, $SoTietMoiBuoiHoc)
		{
			$sql = "UPDATE `tbl_thoigianhoc`
					SET `MaTrangThai` = '$MaTrangThai', `ChuThich` = '$ChuThich', `SoTietMoiBuoiHoc` = '$SoTietMoiBuoiHoc'
					WHERE `MaThoiGianHoc` = '$MaThoiGianHoc'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaThoiGianHoc, $MaTrangThai, $ChuThich, $SoTietMoiBuoiHoc)
		{
			$sql = "SELECT * FROM `tbl_thoigianhoc` WHERE 1  ";
			if($MaThoiGianHoc != "")
				$sql .= " AND `MaThoiGianHoc` = '$MaThoiGianHoc' ";

			if($MaTrangThai != -1)
				$sql .= " AND `MaTrangThai` = '$MaTrangThai' ";

			if($ChuThich != "")
				$sql .= " AND `ChuThich` = '$ChuThich' ";

			if($SoTietMoiBuoiHoc != -1)
				$sql .= " AND `SoTietMoiBuoiHoc` = '$SoTietMoiBuoiHoc' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

